package com.systemframework.sys.controller;


import com.systemframework.annotation.LicenseAnnotation;
import com.systemframework.cos.CosConfigure;
import com.systemframework.oss.OssConfigure;
import com.systemframework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author summer
 * @date 2023-03-22 13:47
 */
@RestController
@RequestMapping(value = "/upload")
@AllArgsConstructor
public class UploadFileController {

  private final OssConfigure ossConfigure;

  private final CosConfigure cosConfigure;


  @LicenseAnnotation
  @PostMapping(value = "/oss_file")
  public Result<String> uploadOssFile(@RequestParam("file") MultipartFile file) {
    return Result.successResult(ossConfigure.uploadFile(file));
  }


  @LicenseAnnotation
  @PostMapping(value = "/cos_file")
  public Result<String> uploadCosFile(@RequestParam("file") MultipartFile file) {

    return Result.successResult(cosConfigure.putFile(file));
  }
}
